CLASSES = types.class reader.class printer.class env.class core.class

all: ${CLASSES}

dist: mal.jar

step1_read_print.groovy: types.class reader.class printer.class
step2_eval.groovy: types.class reader.class printer.class
step3_env.groovy: types.class reader.class printer.class env.class
step4_if_fn_do.groovy step6_file.groovy step7_quote.groovy step8_macros.groovy step9_try.groovy stepA_mal.groovy: ${CLASSES}

types.class: types.groovy
	groovyc $<

env.class: env.groovy
	groovyc $<

reader.class: reader.groovy
	groovyc $<

printer.class: printer.groovy
	groovyc $<

core.class: core.groovy types.class reader.class printer.class
	groovyc $<

mal.jar: ${CLASSES}
	groovyc stepA_mal.groovy
	GROOVY_HOME=/usr/share/groovy groovy GroovyWrapper -d $@ -m stepA_mal

SHELL := bash
mal: mal.jar
	cat <(echo -e '#!/bin/sh\nexec java -jar "$$0" "$$@"') mal.jar > $@
	chmod +x mal

clean:
	rm -f *.class classes/* mal.jar mal
	rmdir classes || true
